﻿@model CategoryModel
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var categoryUrl = Url.RouteUrl("Category", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(categoryUrl);
    }

    var breadcrumbDelimiter = EngineContext.Current.Resolve<CommonSettings>().BreadcrumbDelimiter;
}
@using Nop.Core;
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Web;
@using Nop.Web.Framework;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;

<div class="page category-page">
    @Html.Widget("categorydetails_top")
    @*category breadcrumb*@
    @if (Model.DisplayCategoryBreadcrumb)
    {
        <div class="breadcrumb">
            <ul>
                <li><a href="@Url.RouteUrl("HomePage")" title="@T("Categories.Breadcrumb.Top")">@T("Categories.Breadcrumb.Top")</a>
                    <span class="delimiter">@breadcrumbDelimiter</span> </li>
                @foreach (var cat in Model.CategoryBreadcrumb)
                {
                    var isLastCategory = cat.Id == Model.Id;
                    <li>
                        @if (isLastCategory)
                        {
                            <strong class="current-item">@cat.Name</strong>
                        }
                        else
                        {
                            <a href="@Url.RouteUrl("Category", new { SeName = cat.SeName })" title="@cat.Name">@cat.Name</a>
                            <span class="delimiter">@breadcrumbDelimiter</span>
                        }
                    </li>
                }
            </ul>
        </div>
        @Html.Widget("categorydetails_after_breadcrumb")
    }
@*description*@
    @if (!String.IsNullOrWhiteSpace(Model.Description))
    {
        <div class="category-description">
            @Html.Raw(Model.Description)
        </div>
    }
    @Html.Widget("categorydetails_before_subcategories")
    @*subcategories*@
    @if (Model.SubCategories.Count > 0)
    {
        <div class="sub-category-grid">
            <div class="item-grid">
                <!--grid-header-->
                @foreach (var item in Model.SubCategories)
                {
                    <div class="item-box">
                        <div class="sub-category-item">
                            <h2 class="title">
                                <a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">@item.Name</a>
                            </h2>
                            <div class="picture">
                                <a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
                                    <img alt="@item.PictureModel.AlternateText" src="@item.PictureModel.ImageUrl" title="@item.PictureModel.Title" />
                                </a>
                            </div>
                        </div>
                    </div>
                }
            </div>
        </div>
    }
    @Html.Widget("categorydetails_before_featured_products")

    @*featured products*@
    @if (Model.FeaturedProducts.Count > 0)
    {
        <div class="product-grid featured-product-grid">
            <div class="grid-header">
                <h2 class="title">@T("Products.FeaturedProducts")</h2>
            </div>
            <div class="item-grid">
                @foreach (var item in Model.FeaturedProducts)
                {
                    <div class="item-box">
                        @Html.Partial("_ProductBox", item)
                    </div>
                }
            </div>
        </div>
    }
    @Html.Widget("categorydetails_after_featured_products")
    <div class="product-selectors">
        @*view mode*@
        @if (Model.PagingFilteringContext.AllowProductViewModeChanging && Model.Products.Count > 0)
        {
            <div class="product-viewmode filtersDropDownPanel">
                <span>@T("Categories.ViewMode")</span>
                @Html.DropDownList("products-viewmode", Model.PagingFilteringContext.AvailableViewModes, new { onchange = "setLocation(this.value);" })
            </div>
        }   
    
    
@*sorting*@
        @if (Model.PagingFilteringContext.AllowProductSorting && Model.Products.Count > 0)
        {
            <div class="product-sorting filtersDropDownPanel">
                <span>@T("Categories.OrderBy")</span>
                @Html.DropDownList("products-orderby", Model.PagingFilteringContext.AvailableSortOptions, new { onchange = "setLocation(this.value);" })
            </div>
        }
    
@*page size*@
        @if (Model.PagingFilteringContext.AllowCustomersToSelectPageSize && Model.Products.Count > 0)
        {
            <div class="product-page-size filtersDropDownPanel">
                <span>@T("Categories.PageSize")</span>
                @Html.DropDownList("products-pagesize", Model.PagingFilteringContext.PageSizeOptions, new { onchange = "setLocation(this.value);" })
                <span>@T("Categories.PageSize.PerPage")</span>
            </div>
        }
    </div>
    <!--grid-display-options-->
    @Html.Widget("categorydetails_before_filters")
    @*filtering*@
    @if (Model.PagingFilteringContext.PriceRangeFilter.Enabled || Model.PagingFilteringContext.SpecificationFilter.Enabled)
    {
        <div class="product-filters-wrapper">
            @*filtering*@
            @if (Model.PagingFilteringContext.PriceRangeFilter.Enabled)
            {
                @Html.Partial("_FilterPriceBox", Model.PagingFilteringContext.PriceRangeFilter, new ViewDataDictionary())
            }
@*filtering*@
            @if (Model.PagingFilteringContext.SpecificationFilter.Enabled)
            {
                @Html.Partial("_FilterSpecsBox", Model.PagingFilteringContext.SpecificationFilter, new ViewDataDictionary())
            }
        </div>
    }
    @Html.Widget("categorydetails_before_product_list")
    @*product list*@
    @if (Model.Products.Count > 0)
    {
        <div class="category-title">
            <h2 class="title">@Model.Name</h2>
        </div>
        <!--category-title-->
        
        if (Model.PagingFilteringContext.ViewMode == "list")
        {
@*list mode*@
        <div class="product-list">
            <div class="item-grid">
                @foreach (var product in Model.Products)
                {
                    <div class="item-box">
                        @Html.Partial("_ProductBox", product)
                    </div>
                }
            </div>
        </div>       
        }
        else
        {
@*grid mode*@
        <div class="product-grid">
            <div class="item-grid">
                @foreach (var item in Model.Products)
                {
                    <div class="item-box">
                        @Html.Partial("_ProductBox", item)
                    </div>
                }
            </div>
        </div>
        }
    }
    <div class="pager">
        @if (Model.PagingFilteringContext.TotalPages > 1)
        {
            <div>
                @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
            </div>                
            <div class="corner"></div>
        }
    </div>
    @Html.Widget("categorydetails_bottom")
</div>
